package com.sky.controller.admin;

import com.sky.dto.order.OrderSelectDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.Order.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 褚金龙
 * @Date 2024/10/6 9:15
 */
@RestController("adminOrderController")
@RequestMapping("/admin")
@CrossOrigin("*")
@Api(tags = "管理端订单相关接口")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/order/query")
    @ApiOperation("分页查询订单")
 public Result<PageResult> selectOrder(@RequestBody OrderSelectDTO orderSelectDTO){
        log.info("orderSelectDTO{}",orderSelectDTO);
        PageResult pageResult = orderService.select(orderSelectDTO);
        return Result.success(pageResult);
 }

    @PostMapping("/order/updateStatus/{id}")
    @ApiOperation("修改订单状态")
    public Result updateOrderStatus(@PathVariable Long id,@RequestBody Integer status){
        log.info("number{} status{}",id,status);
        orderService.updateOrderStatus(id,status);
        return Result.success();
    }


    @GetMapping("/order/delete/{id}")
    @ApiOperation("删除订单")
    public Result deleteOrder(@PathVariable Long id){
        orderService.remove(id);
        log.info("orderNumber{}",id);
        return Result.success();
    }




}
